package com.intsig.airflow.web.model;


import lombok.Data;

import java.io.Serializable;
import java.util.Objects;

/**
 * DAG中节点边关系数据模型
 *
 * @author leojie 2021/3/13 1:54 下午
 */

public class DagEdge implements Serializable {
    public static final String ID = "id";
    public static final String SRC_NODE_ID = "src_node_id";
    public static final String SRC_OUTPUT_IDX = "src_output_idx";
    public static final String DST_NODE_ID = "dst_node_id";
    public static final String DST_INPUT_IDX = "dst_input_idx";

    /**
     * 边id
     */
    private Long id;
    /**
     * 边出发的节点ID
     */
    private Long srcNodeId;
    private Integer srcOutputIdx;
    /**
     * 边指向的节点ID
     */
    private Long dstNodeId;
    private Integer dstInputIdx;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getSrcNodeId() {
        return srcNodeId;
    }

    public void setSrcNodeId(Long srcNodeId) {
        this.srcNodeId = srcNodeId;
    }

    public Integer getSrcOutputIdx() {
        return srcOutputIdx;
    }

    public void setSrcOutputIdx(Integer srcOutputIdx) {
        this.srcOutputIdx = srcOutputIdx;
    }

    public Long getDstNodeId() {
        return dstNodeId;
    }

    public void setDstNodeId(Long dstNodeId) {
        this.dstNodeId = dstNodeId;
    }

    public Integer getDstInputIdx() {
        return dstInputIdx;
    }

    public void setDstInputIdx(Integer dstInputIdx) {
        this.dstInputIdx = dstInputIdx;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        DagEdge that = (DagEdge) o;
        return srcNodeId.longValue() == that.srcNodeId.longValue() && dstNodeId.longValue() == that.dstNodeId.longValue();
    }

    @Override
    public int hashCode() {
        return Objects.hash(srcNodeId, dstNodeId);
    }

    @Override
    public String toString() {
        return "DagEdgeEntity{" +
                "id=" + id +
                ", srcNodeId=" + srcNodeId +
                ", srcOutputIdx=" + srcOutputIdx +
                ", dstNodeId=" + dstNodeId +
                ", dstInputIdx=" + dstInputIdx +
                '}';
    }
}
